package com.beemans.common.ext

import com.beemans.common.R
import com.beemans.common.data.constant.CommonStore
import com.gyf.immersionbar.ImmersionBar
import com.gyf.immersionbar.ktx.hasNavigationBar
import com.gyf.immersionbar.ktx.immersionBar
import com.tiamosu.fly.base.BaseFlyActivity
import com.tiamosu.fly.base.BaseFlyFragment
import com.tiamosu.fly.base.dialog.BaseFlyDialogFragment

/**
 * @author tiamosu
 * @date 2021/3/18.
 */

/**
 * 沉浸式配置，设置导航栏颜色为白色
 */
inline fun BaseFlyActivity.immersionBarExt(block: ImmersionBar.() -> Unit = {}) {
    immersionBar {
        statusBarColor(R.color.transparent)
        statusBarDarkFont(false)
        if (hasNavigationBar) {
            navigationBarColor(R.color.white)
            navigationBarDarkIcon(true)
        }
        block.invoke(this)
        CommonStore.immersionBarParams = barParams
    }
}

/**
 * 沉浸式配置，设置导航栏颜色为白色
 */
inline fun BaseFlyFragment.immersionBarExt(block: ImmersionBar.() -> Unit = {}) {
    immersionBar {
        statusBarColor(R.color.transparent)
        statusBarDarkFont(false)
        if (hasNavigationBar) {
            navigationBarColor(R.color.white)
            navigationBarDarkIcon(true)
        }
        block.invoke(this)
        CommonStore.immersionBarParams = barParams
    }
}

/**
 * 沉浸式配置，设置导航栏颜色为白色
 */
inline fun BaseFlyDialogFragment.immersionBarExt(block: ImmersionBar.() -> Unit = {}) {
    immersionBar {
        val params = CommonStore.immersionBarParams
        statusBarColor(R.color.transparent)
        statusBarDarkFont(params?.statusBarDarkFont ?: true)
        if (hasNavigationBar) {
            navigationBarColor(R.color.transparent)
            navigationBarDarkIcon(params?.navigationBarDarkIcon ?: true)
        }
        block.invoke(this)
        CommonStore.immersionBarParams = barParams
    }
}